// 
// DotNetNuke?- http://www.dotnetnuke.com 
// Copyright (c) 2002-2011 
// by DotNetNuke Corporation 
// 
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 
// documentation files (the "Software"), to deal in the Software without restriction, including without limitation 
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and 
// to permit persons to whom the Software is furnished to do so, subject to the following conditions: 
// 
// The above copyright notice and this permission notice shall be included in all copies or substantial portions 
// of the Software. 
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 
// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 
// CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
// DEALINGS IN THE SOFTWARE. 
// 

using System;
using System.Configuration;
using System.Data;
using System.Xml;
using System.Web;
using System.Collections.Generic;

using DotNetNuke;
using DotNetNuke.Common;
using DotNetNuke.Common.Utilities;
using DotNetNuke.Services.Search;
using DotNetNuke.Entities.Modules;

namespace CharityGamesOnline.Modules.Account
{

    /// ----------------------------------------------------------------------------- 
    /// <summary> 
    /// The Controller class for Account 
    /// </summary> 
    /// <remarks> 
    /// </remarks> 
    /// <history> 
    /// </history> 
    /// ----------------------------------------------------------------------------- 
    public class AccountController
    {

        #region "Public Methods"

        public AccountInfo GetAccount(int portalID, int  userID)
		{
			return (AccountInfo)CBO.FillObject(DataProvider.Instance().GetAccount(portalID,userID), typeof(AccountInfo));
		}

		public List<AccountInfo> GetAccounts(int portalID)
		{
			return CBO.FillCollection<AccountInfo>(DataProvider.Instance().GetAccounts(portalID));
		}                
	
		public void SaveAccount(AccountInfo objAccount)
		{
            DataProvider.Instance().SaveAccount(objAccount.PortalID, objAccount.UserID, objAccount.Token);
		}
			
		public void Delete(int portalID,int  userID)
		{
            DataProvider.Instance().DeleteAccount(portalID, userID);
		}

        public void SaveAccountLog(AccountLogInfo objAccountLog)
        {
            DataProvider.Instance().SaveAccountLog(objAccountLog.PortalID, objAccountLog.UserID, objAccountLog.Token, 
                                                   objAccountLog.PaymentID, objAccountLog.Comment);
        }

        public List<AccountLogInfo> GetAccountLogs(int portalID, int userID)
        {
            return GetAccountLogs(portalID, userID, false, 0, 0);
        }

        public List<AccountLogInfo> GetAccountLogs(int portalID, int userID, bool getCount, int pageSize, int currentPage)
        {
            return CBO.FillCollection<AccountLogInfo>(DataProvider.Instance().GetAccountLogs(portalID, userID, getCount, pageSize, currentPage));
        }


        #endregion        

    }


    public class PaymentController
    {
        #region "Public Methods"
        public PaymentInfo GetPayment(int portalID, int paymentID)
        {
            return (PaymentInfo)CBO.FillObject(DataProvider.Instance().GetPayment(portalID, paymentID), typeof(PaymentInfo));
        }

        public List<PaymentInfo> GetPayments(int portalID, int userID, int statusID)
        {
            return GetPayments(portalID, userID, 0, statusID, false, 0, 0);
        }

        public List<PaymentInfo> GetPayments(int portalID, int userID, int enrollmentID, int statusID)
        {
            return GetPayments(portalID, userID, enrollmentID, statusID, false, 0, 0);
        }

        public List<PaymentInfo> GetPayments(int portalID, int userID, int statusID, bool getCount, int pageSize, int currentPage)
        {
            return GetPayments(portalID, userID, 0, statusID, getCount, pageSize, currentPage);
        }

        public List<PaymentInfo> GetPayments(int portalID, int userID, int enrollmentID, int statusID, bool getCount, int pageSize, int currentPage)
		{
            return CBO.FillCollection<PaymentInfo>(DataProvider.Instance().GetPayments(portalID, userID, enrollmentID, statusID, getCount, pageSize, currentPage));
		}


        public int SavePayment(PaymentInfo objPayment)
        {
            return (int)DataProvider.Instance().SavePayment(objPayment.PaymentID, objPayment.PortalID, objPayment.UserID, objPayment.Amount, objPayment.StatusID, objPayment.EnrollmentID);
        }
        
        public void Delete(int portalID,int paymentID)
        {
            DataProvider.Instance().DeletePayment(portalID, paymentID);
        }

        public PaymentLogInfo GetPaymentLog(int paymentLogID)
        {
            return (PaymentLogInfo)CBO.FillObject(DataProvider.Instance().GetPaymentLog(paymentLogID), typeof(PaymentLogInfo));
        }

        public List<PaymentLogInfo> GetPaymentLogs(int paymentID)
        {
            return CBO.FillCollection<PaymentLogInfo>(DataProvider.Instance().GetPaymentLogs(paymentID));
        }

        public int SavePaymentLog(PaymentLogInfo objPaymentLog)
        {
            return (int)DataProvider.Instance().SavePaymentLog(objPaymentLog.PaymentLogID, objPaymentLog.PaymentID, objPaymentLog.AppID,
                objPaymentLog.ProductKey, objPaymentLog.ProductQuantity, objPaymentLog.TransactionID, objPaymentLog.TransType,
                objPaymentLog.ApprovalCode, objPaymentLog.IsTest, objPaymentLog.PageNumber, objPaymentLog.ReceiptNumber, objPaymentLog.SalesOrderNumber);
        }

        #endregion        
    }    
}